<?php
require_once 'PHPUnit/Framework.php';
require_once 'helper.php';
 
class HelperTest extends PHPUnit_Framework_TestCase
{
  public function test_removeExtension_empty()
  {
    $this->assertEquals(null, removeExtension(null));
    $this->assertEquals("", removeExtension(""));
  }

  public function test_removeExtension_noExtension()
  {
    $this->assertEquals("a", removeExtension("a"));
    $this->assertEquals("abc", removeExtension("abc"));
  }  

  public function test_removeExtension_extension()
  {
    $this->assertEquals("", removeExtension("."));
    $this->assertEquals("a", removeExtension("a."));
    $this->assertEquals("abc", removeExtension("abc.t"));
    $this->assertEquals("ab", removeExtension("ab.tasfasdf"));
  }  

  public function test_removeExtension_multipleEtension()
  {
    $this->assertEquals("a.b", removeExtension("a.b."));
    $this->assertEquals("abc.t", removeExtension("abc.t.def"));
    $this->assertEquals("ab.tasfasdf", removeExtension("ab.tasfasdf.123"));
  }
  
  public function test_nextFilename_set()
  {
    $this->assertEquals("a", nextFilename("a.b"));
  }

  public function test_nextFilename_new()
  {
    $this->assertEquals("grin/newfile", substr(nextFilename(""),0,12));
  }
  
  public function test_nextFilename_random()
  {
    $one = nextFilename("");
    $two = nextFilename("");
    $this->assertEquals(false,$one == $two);
  }

  
}
?>